package com.bjpowernode.task;

import com.bjpowernode.service.IncomeService;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.rpc.proxy.jdk.JdkProxyFactory;
import org.springframework.aop.framework.AopProxy;
import org.springframework.stereotype.Component;
@Component("taskManager")
public class TaskManager  {

    /**
     * 定义方法，实现定时任务
     * 要求：
     *  1.没有返回值
     *  2.没有参数
     *  3.public方法
     */

//    @Scheduled(cron = "*/3 * * * * ?")//每隔三秒做一次
//    public void testCron(){
//        System.out.println("定时任务="+new Date());
//    }

    //定义远程对象的引用
    @DubboReference(interfaceClass = IncomeService.class)
    private IncomeService incomeService;

    //生成收益计划
    //@Scheduled(cron = "0 */20 * * * ?")//每20分钟做一次
    public void generateIncomePlan(){
        //以消费者的身份，调用远程接口
        incomeService.generateIncomePlan();
    }

    //收益返还
    //@Scheduled(cron = "0 0 */1 * * ?")//每1小时分钟做一次
    public void generateIncomeBack(){
        //以消费者的身份，调用远程接口
        incomeService.generateIncomeBack();
    }

}
